#include <bits/stdc++.h>
#define gc getchar
#define pc putchar
#define pt printf
#define IL inline
#define For(i,a,b) for(int i=a;i<=b;++i)
#define Rof(i,a,b) for(int i=a;i>=b;++i) 
using namespace std;
const int Mxn=2005,Mxk=Mxn*Mxn;
int N,M,Q,Fa[Mxk];
char S[Mxn][Mxn];
int _() {
	int x=0,f=0;char ch=gc();
	while(ch<'0'||ch>'9') f|=(ch=='-'),ch=gc();
	while(ch>='0'&&ch<='9') x=(x<<1)+(x<<3)+(ch^48),ch=gc();
	return f?-x:x;
}
void __(int x) {
	int stk[30],tp=0;
	if(x<0) x=-x,pc('-');
	do stk[++tp]=x%10,x/=10;while(x);
	while(tp) pc(stk[tp--]^48);
}
int Find(int x) {return x==Fa[x]?x:Fa[x]=Find(Fa[x]);}
void Union(int x,int y) {
//	pt("[%d %d] \n",x,y);
	if(Find(x)==Find(y)) return ;
	Fa[Find(y)]=Find(x);
}
signed main() {//20
	freopen("unicom.in","r",stdin);
	freopen("unicom.out","w",stdout);
	N=_(),M=_(),Q=_();
	For(i,1,N) scanf("%s",S[i]+1);
	while(Q--) {
		int x1=_(),y1=_(),x2=_(),y2=_(),Res=0;
		For(i,x1,x2) For(j,y1,y2) if(S[i][j]=='1') {
			int x=(i-1)*M+j;
			Fa[x]=x;
//			pt("(%d %d) %d\n",i,j,x);
			if(i>x1&&S[i-1][j]=='1') Union(x,x-M);
			if(j>y1&&S[i][j-1]=='1') Union(x,x-1);
		}
		For(i,x1,x2) For(j,y1,y2) {
			if(S[i][j]=='1'&&Find((i-1)*M+j)==(i-1)*M+j) Res++;
		}
//		pt("______________________________");
		__(Res),pc('\n');
	}
	return 0;
}
